<?php
include_once("database.php");
header("Content-Type:image/png");

$query = 'SELECT * FROM `itemimage` WHERE MaterialId="'.$_GET["id"].'";';
$stmt = $db->query($query);
$image = $stmt -> fetch_assoc();

echo $image["file_data"];
?>